//
//  LoginAppDelegate.m
//  Login
//
//  Created by Sean on 3/23/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "LoginAppDelegate.h"
#import "LockScreenView.h"
#import "FileHandler.h"

@implementation LoginAppDelegate

@synthesize window;

static BOOL dirty = NO;


+(BOOL)isDirty
{
	return dirty;
}

+(void)setDirty:(BOOL) isDirty
{
	dirty= isDirty;
}



- (void)applicationDidFinishLaunching:(UIApplication *)application {    
    
	bImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
	
	lock =[[LockScreenView alloc] initLockScreen:self:bImage];
	[window addSubview:lock];
	[lock release];
	
    [window makeKeyAndVisible];
}

-(void)inputSucceded
{
	viewController = [[LoginTableViewController alloc] init];
	//[lock removeFromSuperview];
	UINavigationController *accountNav = [[UINavigationController alloc] initWithRootViewController:viewController];
	[window addSubview:accountNav.view];
	
	[lock removeFromSuperview];
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
	[FileHandler saveAllLoginsToFile:[viewController getAllLogins]];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
	
}


- (void)applicationWillTerminate:(UIApplication *)application
{
	[FileHandler saveAllLoginsToFile:[viewController getAllLogins]];
}

- (void)dealloc {
	[bImage release];
    [viewController release];
    [window release];
    [super dealloc];
}


@end
